package presentacion;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextPane;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import java.awt.Insets;

import javax.swing.ComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;

import negocio.TransferGeneral;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.awt.Component;

public class GUIGeneralLeerCorreo extends JDialog {

	
	JTextField comboBoxPara;
	JTextField textPane ;
	JTextPane textPaneContenido;
	ArrayList<Integer> usuarioId;
	private int dniUsuario;
	private int idCorreo;
	
	private final JPanel contentPanel = new JPanel();
	private JTextField textField;


	/**
	 * Create the dialog.
	 */
	public GUIGeneralLeerCorreo(int idCor,boolean marcarLeido) {

		idCorreo=idCor;
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		GridBagLayout gbl_contentPanel = new GridBagLayout();
		gbl_contentPanel.columnWidths = new int[]{54, 6, 51, 0};
		gbl_contentPanel.rowHeights = new int[]{0, 20, 0, 0, 0};
		gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
		gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
		contentPanel.setLayout(gbl_contentPanel);
		{
			JLabel lblDe = new JLabel("De:");
			GridBagConstraints gbc_lblDe = new GridBagConstraints();
			gbc_lblDe.anchor = GridBagConstraints.EAST;
			gbc_lblDe.insets = new Insets(0, 0, 5, 5);
			gbc_lblDe.gridx = 0;
			gbc_lblDe.gridy = 0;
			contentPanel.add(lblDe, gbc_lblDe);
		}
		{
			textField = new JTextField();
			textField.setEditable(false);
			GridBagConstraints gbc_textField = new GridBagConstraints();
			gbc_textField.insets = new Insets(0, 0, 5, 5);
			gbc_textField.fill = GridBagConstraints.HORIZONTAL;
			gbc_textField.gridx = 1;
			gbc_textField.gridy = 0;
			contentPanel.add(textField, gbc_textField);
			textField.setColumns(10);
		}
		
			JLabel lblFecha = new JLabel("fecha");
			GridBagConstraints gbc_lblFecha = new GridBagConstraints();
			gbc_lblFecha.insets = new Insets(0, 0, 5, 0);
			gbc_lblFecha.gridx = 2;
			gbc_lblFecha.gridy = 0;
			contentPanel.add(lblFecha, gbc_lblFecha);
		
		{
			JLabel lblPara = new JLabel("Para:");
			GridBagConstraints gbc_lblPara = new GridBagConstraints();
			gbc_lblPara.anchor = GridBagConstraints.EAST;
			gbc_lblPara.insets = new Insets(0, 0, 5, 5);
			gbc_lblPara.gridx = 0;
			gbc_lblPara.gridy = 1;
			contentPanel.add(lblPara, gbc_lblPara);
		}
		{
			comboBoxPara = new JTextField();
			comboBoxPara.setEditable(false);
			GridBagConstraints gbc_comboBoxPara = new GridBagConstraints();
			gbc_comboBoxPara.insets = new Insets(0, 0, 5, 5);
			gbc_comboBoxPara.fill = GridBagConstraints.HORIZONTAL;
			gbc_comboBoxPara.gridx = 1;
			gbc_comboBoxPara.gridy = 1;
			contentPanel.add(comboBoxPara, gbc_comboBoxPara);
		}
		
			JLabel lblAsunto = new JLabel("Asunto:");
			lblAsunto.setAlignmentX(Component.CENTER_ALIGNMENT);
			GridBagConstraints gbc_lblAsunto = new GridBagConstraints();
			gbc_lblAsunto.anchor = GridBagConstraints.EAST;
			gbc_lblAsunto.insets = new Insets(0, 0, 5, 5);
			gbc_lblAsunto.gridx = 0;
			gbc_lblAsunto.gridy = 2;
			contentPanel.add(lblAsunto, gbc_lblAsunto);
		
		{
			textPane = new JTextField();
			textPane.setEditable(false);
			GridBagConstraints gbc_textPane = new GridBagConstraints();
			gbc_textPane.insets = new Insets(0, 0, 5, 5);
			gbc_textPane.fill = GridBagConstraints.BOTH;
			gbc_textPane.gridx = 1;
			gbc_textPane.gridy = 2;
			contentPanel.add(textPane, gbc_textPane);
		}
		{
			JScrollPane scrollPane = new JScrollPane();
			GridBagConstraints gbc_scrollPane = new GridBagConstraints();
			gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
			gbc_scrollPane.gridwidth = 3;
			gbc_scrollPane.fill = GridBagConstraints.BOTH;
			gbc_scrollPane.gridx = 0;
			gbc_scrollPane.gridy = 3;
			contentPanel.add(scrollPane, gbc_scrollPane);
			{
				textPaneContenido = new JTextPane();
				textPaneContenido.setEditable(false);
				scrollPane.setViewportView(textPaneContenido);
			}
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			
		}
		
		TransferGeneral datos=new TransferGeneral();

		datos.setIdCorreoLeer(idCorreo);
		
		SingletonControlador.getInstancia().evento(Evento.GENERAL_LEER_CORREO, datos);
		
		comboBoxPara.setText(datos.getNombreDestinoLeer()+" "+datos.getApellido1DestinoLeer()+" "+datos.getApellido2DestinoLeer());
		
		textField.setText(datos.getNombreOrigenLeer()+" "+datos.getApellido1OrigenLeer()+" "+datos.getApellido2OrigenLeer());

		textPaneContenido.setText(datos.getContenidoLeer());
		
		textPane.setText(datos.getAsuntoLeer());
		lblFecha.setText(datos.getFechaLeer());
		
		
		
	
	}








}
